package learn.cwebsitelearn.chapter8;

/**
 * @AUTHOR LYF
 * @DATE 2022/3/26
 * @VERSION 1.0
 * @DESC
 */
public class Test {
    int c;
    public static void main(String[] args) {

//        int c;
//        System.out.println(new Test().c);

        String a = "a";
        String b = "b";
        String str1 = "a" + "b";//常量池中的对象
        String str2 = a + b; //在堆上创建的新的对象
        String str3 = "ab";//常量池中的对象
        String str4 = a+"b";//在堆上分配的新对象
        String str5 = new String(str4);//分配的新对象
        String str6 = str5;
        System.out.println(str1 == str2);//false
        System.out.println(str1 == str3);//true
        System.out.println(str2 == str3);//false
        System.out.println(str3 == str4);//false
        System.out.println(str4 == str5);//false
        System.out.println(str5 == str6);//true

    }
}
